<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <title>编辑对战</title>
    <link rel="stylesheet" th:href="@{../../static/layui/css/layui.css}" href="../../static/layui/css/layui.css" media="all">
</head>

<body>

<form class="layui-form" action="" >
    <div class="layui-form-item">
        <label class="layui-form-label">比赛ID</label>
        <div class="layui-input-block">
            <input readonly type="text" th:value="${match.getMid()}" name="mid" required  lay-verify="required" autocomplete="off" class="layui-input">
            <input readonly type="hidden" th:value="${match.getMatchId()}" name="matchId" required  lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">选手1</label>
        <div class="layui-input-block">
            <input type="text" name="aName" th:value="${match.getAName()}" required  lay-verify="required"  autocomplete="off" class="layui-input">
            <input type="hidden" name="playerA" th:value="${match.getPlayerA()}" required  lay-verify="required"  autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">选手1歌曲</label>
        <div class="layui-input-block">
            <input type="text" name="aSong" th:value="${match.getASong()}" required  lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">选手2</label>
        <div class="layui-input-block">
            <input type="text" name="bName"  th:value="${match.getBName()}"  required  lay-verify="required" autocomplete="off" class="layui-input">
            <input type="hidden" name="playerB"  th:value="${match.getPlayerB()}"  required  lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">选手2歌曲</label>
        <div class="layui-input-block">
            <input type="text" name="bSong" th:value="${match.getBSong()}" required  lay-verify="required" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">比赛状态</label>
        <div class="layui-input-block">
            <select name="mStatus" lay-verify="required">
                <option name="mStatus" th:selected="${match.getMStatus()==1}" value="1">比赛开启</option>
                <option name="mStatus" th:selected="${match.getMStatus()==0}" disabled value="0">未开始</option>
                <option name="mStatus" th:selected="${match.getMStatus()==2}" value="2">比赛结束</option>
                <option name="mStatus" th:selected="${match.getMStatus()==3}" value="3">比赛暂停</option>
            </select>
        </div>

    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script th:src="@{../../static/layui/layui.js}"></script>
<script th:src="@{../../static/js/eleDel.js}" type="text/javascript"></script>
<script th:src="@{../../static/mysource/js/jquery-3.3.1.min.js}"></script>
<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;
        var layer = layui.layer


        //提交
        form.on('submit(formDemo)', function(data){
            console.log(data)

            $.ajax({
                url: '/match/update' ,
                dataType:"json",
                type:"post",
                data: data.field,
                success:function (data){
                    console.log(data)
                    if (data.flag){
                        var msg = data.msg
                        layer.msg(msg,{icon:6});
                    }else{
                        var msg = data.msg
                        layer.msg(msg,{icon:6});
                    }



                }
            })
            return false;
        });
    });
</script>
</body>

</html>